/*
 * @Author: gyc
 * @Date: 2020-05-26 13:18:40
 * @LastEditTime: 2020-08-26 16:34:57
 * @Description: Nuxt测试版
 */
'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const {
    router,
    controller,
    io
  } = app;

  //user模块
  router.resources('user', '/api/user', controller.user);
  // router.get('/user/islogin', controller.user.islogin);
  router.all('/login', controller.user.login);
  router.all('/logout', controller.user.logout);
  router.all('/isAuthenticated', controller.user.isAuthenticated);
  router.get('/api/user/info', controller.user.getUserinfo)
  router.get('/api/user/updateInfo', controller.user.updateUserinfo)
  router.get('/api/user/userCount', controller.user.userCount)
  router.get('/badLogin', controller.user.badLogin);
  router.post('/api/auth/login', app.passport.authenticate('local', {
    successRedirect: '/login',
    failureRedirect: "/badLogin"
  }));
  router.get('/api/user/userReword',controller.user.userReword)
  router.get('/api/user/userStusCtl',controller.user.userStusCtl)

  //img模块
  router.get('/api/img/getSwiperUrl', controller.img.getSwiperUrl)
  router.get('/api/img/getVedioUrl', controller.img.getVedioImg)
  router.get('/api/img/getHotUrl', controller.img.getHotImg)
  router.post('/api/img/upLoadImg', controller.img.upLoadImg)

  //art模块
  router.post('/api/art/createArt', controller.article.createArt)
  router.get('/api/art/findArt', controller.article.findArtById)//根据ID找文章内容
  router.get('/api/art/findMyArticle', controller.article.findMy)
  router.get('/api/art/deleteMyArticle', controller.article.deleteMyArticle)

  //io模块
  io.of('/').route('chat', io.controller.chat.index);

  //music模块
  router.get('/api/music/findMusic', controller.music.getMusic)
  router.get('/api/music/findAllMusic', controller.music.getAllMusic)

  //share模块
  router.get('/api/share/createShare', controller.share.create)
  router.get('/api/share/findMyShare', controller.share.findMy)
  router.get('/api/share/deleteMyShare', controller.share.deleteMyShare)
};